package logic

import (
	"context"
	"doctor-medicine-system/model/mysql"

	"doctor-medicine-system/goods/goods"
	"doctor-medicine-system/goods/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListLogic {
	return &ListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ListLogic) List(in *goods.ListRequest) (*goods.ListResponse, error) {
	// todo: add your logic here and delete this line
	var data []*goods.ListGoods
	mysql.DB.Model(mysql.Goods{}).Table("goods").Find(&data)
	return &goods.ListResponse{
		List: data,
	}, nil
}
